/**
 * Creat with IntelliJ IDEA
 * Description
 * User: mamba24
 * Date: 2022-07-29
 * Time: 14:35
 * To BE A Better Person-2020-3-2
 */

/**
 * 懒汉模式
 */
class Singleton{
    private static Singleton instance=new Singleton();

    public Singleton getInstance(){
        return instance;
    }

    private Singleton(){}
}

class SingletonLazy{
    private  static SingletonLazy instance=null;
    public SingletonLazy getInstance(){
        //去锁，降低竞争效率。。。。
        if(instance == null){
            synchronized (SingletonLazy.class){
                if(instance == null){
                    instance=new SingletonLazy();
                }
            }
        }


        return instance;
    }
}
public class TestDemo {

}